import type { ButtonProps } from 'element-plus'
import type { ComputedRef } from 'vue'
// import type { VxeModalProps } from 'vxe-pc-ui'

// todo: 会丢失原始组件默认值
// export interface ModalProps extends Omit<VxeModalProps, 'modelValue'> {
export interface ModalProps {
  id?: string
  title?: string
  showFooter?: boolean
  destroyOnClose?: boolean
  showMaximize?: boolean
  showMinimize?: boolean
  mask?: boolean
  lockView?: boolean
  loading?: boolean
  resize?: boolean
  remember?: boolean
  escClosable?: boolean
  beforeHideMethod?: Fn

  visible?: boolean
  okText?: string
  cancelText?: string
  showOkBtn?: boolean
  showCancelBtn?: boolean
  okButtonProps?: ButtonProps
  cancelButtonProps?: ButtonProps
  okType?: ButtonProps['type']
  confirmLoading?: boolean
  helpMessage?: string
}

/**
 * @description: 弹窗对外暴露的方法
 */
export interface ModalMethods {
  setModalProps: (props: Partial<ModalProps>) => void
  emitVisible?: (visible: boolean, uid: number) => void
  redoModalHeight?: () => void
}

export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void

export interface ReturnMethods extends ModalMethods {
  openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void
  closeModal: () => void
  getVisible?: ComputedRef<boolean>
}

export type UseModalReturnType = [RegisterFn, ReturnMethods]

export interface ReturnInnerMethods extends ModalMethods {
  closeModal: () => void
  changeLoading: (loading: boolean) => void
  changeOkLoading: (loading: boolean) => void
  getVisible?: ComputedRef<boolean>
  redoModalHeight: () => void
}

export type UseModalInnerReturnType = [RegisterFn, ReturnInnerMethods]
